//
//  PFindNewsFlashCell.m
//  Btpin
//
//  Created by Vic on 2020/1/1.
//  Copyright © 2020 Vic. All rights reserved.
//

#import "PFindNewsFlashCell.h"

@interface PFindNewsFlashCell ()
{
    UIView *bgView;
    UIImageView *timeImgView;
    UILabel *timeLbl;
    UILabel *titleLbl;
    UILabel *detailLbl;
}
@end

@implementation PFindNewsFlashCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initUI];
    }
    return self;
}
- (void)initUI {
    self.backgroundColor = COLOR_OF_CLEAR;
    self.contentView.backgroundColor = COLOR_OF_CLEAR;
    
    bgView = [UIToolsControl initViewWithFrame:CGRectMake(ScalePS(10), ScalePS(10), WIDTH-ScalePS(20), 100) backgroundColor:COLOR_OF_WHITE];
    bgView.layer.cornerRadius = ScalePS(10);
    bgView.layer.masksToBounds = YES;
    [self.contentView addSubview:bgView];
    
    timeImgView = [UIToolsControl initImageViewWithFrame:CGRectMake(ScalePS(15), ScalePS(25), ScalePS(15), ScalePS(15)) imageName:@"find_time_icon"];
    timeImgView.userInteractionEnabled = YES;
    [bgView addSubview:timeImgView];
    
    timeLbl = [UIToolsControl initLabelWithFrame:CGRectMake(EndX(timeImgView)+ScalePS(8), StartY(timeImgView), 100, ViewHeight(timeImgView)) text:nil textColor:THEMECOLOR_OF_ORANGE font:Font_10];
    [bgView addSubview:timeLbl];
    
    titleLbl = [UIToolsControl initLabelWithFrame:CGRectMake(ScalePS(15), EndY(timeImgView)+ScalePS(5), ViewWidth(bgView)-ScalePS(30), 50) text:nil textColor:THEMECOLOR_OF_TEXT_333333 font:Font_16];
    titleLbl.numberOfLines = 0;
    titleLbl.lineBreakMode = NSLineBreakByWordWrapping;
    [bgView addSubview:titleLbl];
    
    detailLbl = [UIToolsControl initLabelWithFrame:CGRectMake(ScalePS(15), EndY(titleLbl), ViewWidth(bgView)-ScalePS(30), 50) text:nil textColor:THEMECOLOR_OF_TEXT_9a9a9a font:Font_11];
    [bgView addSubview:detailLbl];
}
- (void)reloadDataForModel:(PublishedNewsFlashModel *)model {
    bgView.frame = CGRectMake(ScalePS(10), ScalePS(10), WIDTH-ScalePS(20), model.cellHeight-ScalePS(10));
    [bgView setShadowShadowColor:THEMECOLOR_OF_Line_Color shadowOpacity:2 shadowRadius:2 shadowOffset:CGSizeMake(2, 2)];
    
    timeLbl.text = model.add_timeShow;
    
    titleLbl.frame = CGRectMake(ScalePS(15), EndY(timeImgView)+ScalePS(10), ViewWidth(bgView)-ScalePS(30), model.titleHeight);
    titleLbl.text = model.title;
    NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
    paraStyle.lineSpacing = LineSpacingHeight;
    titleLbl.attributedText = [[NSAttributedString alloc] initWithString:model.title attributes:@{NSFontAttributeName:FontBold(Font_16), NSParagraphStyleAttributeName:paraStyle}];
    
    detailLbl.frame = CGRectMake(ScalePS(15), EndY(titleLbl), ViewWidth(bgView)-ScalePS(30), 30);
    detailLbl.text = model.desc;
}

- (void)awakeFromNib {
    [super awakeFromNib];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

@end
